<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        // const choir = [];
        // console.log(typeof choir);
        //看一个pc 设计稿的时候，不要盯着html 细节，组件 
        //函数 对多行代码的封装，组成一个功能单元
        // 代码工作划分成一个个的函数
        //每个函数都只做一件事
        /*
        @func 组件1000只鸭子的合唱团
        @return
        */
        let duck = {
            sing() {
                console.log("嘎嘎嘎");
            }
        }
        let cat = {
            sing() {
                console.log("喵喵喵");
            }
        }
        let chick = {
            sing() {
                console.log("嘎嘎嘎");
            }
        }
        const choir = [];

        function buildchoir(animal) {
            if (animal.sing && typeof animal.sing === 'function') {
                choir.push(animal);
            }

        }

        for (let i = 0; i < 999; i++) {
            buildchoir(duck);
        }
        buildchoir(chick);
        if (choir.length >= 1000) {
            console.log("招募完成了");
        }
        console.log(typeof duck.sing);
    </script>
</body>

</html>